package com.huike.web.controller.contract;

import com.huike.common.core.domain.AjaxResult;
import com.huike.contract.service.ISysFileService;
import com.huike.contract.service.impl.ISysFileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/common/upload")
public class CommonController {

    @Autowired(required = false)
    private ISysFileService iSysFileService;

    @PostMapping
    public AjaxResult uploadFile(MultipartFile file) {
        try {
            // 上传文件路径
            AjaxResult upload = iSysFileService.upload(file);
            return upload;
        } catch (Exception e) {
            return AjaxResult.error(e.getMessage());
        }
    }
}
